package com.dubbo.cp.logcenter.dubbo;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.dubbo.cp.logcenter.service.LocalLogService;
import com.dubbo.cp.service.LogService;

import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalLock;

@Service
public class LogDubboServiceImpl implements LogService{

	@Autowired
	private LocalLogService localLogService ;
	
	public void sendDemoLog(String logText) {
		
		System.out.println("sendDemoLog 全局事务id ：" + RootContext.getXID());
		localLogService.sendDemoLog(logText);
	}
//    @GlobalLock
//    @Transactional(rollbackFor = {Throwable.class})
	public void sendUserLog(String username, String logText) {
		
		System.out.println("sendUserLog 全局事务id ：" + RootContext.getXID());
		localLogService.sendUserLog("ADMIN", logText);
//		localLogService.sendDemoLog(username+" ===>>> "+logText);
//		throw new RuntimeException("Test Rollback");
	}

}
